package com.gulimall.auth.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * @Description
 * @Author lhj
 * @Date 2024/3/10 13:57
 */
@Configuration
public class SessionConfig {


    /**
     * cookie 配置
     * @return
     */
    @Bean
    public CookieSerializer cookieSerializer() {
        DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
        //设置cookie名称
        cookieSerializer.setCookieName("JSESSIONID");
        //设置cookie的作用域
        cookieSerializer.setDomainName("gulimall.com");
        return cookieSerializer;
    }

    /**
     * Redis序列化配置
     * @return redisSerializer
     */
    @Bean
    public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
        return new GenericJackson2JsonRedisSerializer();
    }


}
